<?php
/**
 * Arquivo que conterá a listagem de endereço com mapas
 * 
 * @author Alberto Medeiros e Bruno Rafael 
 */

$arrObjEndereco = $view->result;
?>
<a name="investidores"></a>
<div class="maps">
    <?php $objEndereco = $arrObjEndereco[0]; ?>
    <?php print drupal_render($objEndereco->field_field_localizacao);  ?>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <ul class="lista-enderecos">
                <?php
                $contador = 0;
                foreach($arrObjEndereco as $objEndereco):
                    
                    $cep    = $objEndereco->field_field_cep[0]["rendered"]["#markup"];
                    $end    = $objEndereco->field_field_endereco[0]["rendered"]["#markup"];
                    $num    = $objEndereco->field_field_numero[0]["rendered"]["#markup"];
                    $comp   = $objEndereco->field_field_comp[0]["rendered"]["#markup"];
                    $bairro = $objEndereco->field_field_bairro[0]["rendered"]["#title"];
                    $cidade = $objEndereco->field_field_cidade[0]["rendered"]["#title"];
                    $uf     = $objEndereco->field_field_estado[0]["rendered"]["#title"];
                    $estado = $objEndereco->field_field_estado[0]["rendered"]["#options"]["entity"]->field_nome_full["und"][0]["value"];
                    $cnpj   = $objEndereco->_field_data["tid"]["entity"]->field_cnpj["und"][0]["value"];
                    $titulo = $objEndereco->_field_data["tid"]["entity"]->name;
                    
                    $end_full = $end .", ". $num .", ". $bairro .", ".$cidade;
                    
                ?>
                <li class="enderecos <?php if ($contador == 0) { print "select-map"; } ?>" onclick="codeAddress('<?php print $end_full; ?>');">
                    <?php
                        echo "<h3>". $titulo ."</h3>";
                        echo "Endereço: ". $end .", n°". $num ." - ". $comp .", ". $bairro .", ". $cidade ."/". $uf ."<br>"; 
                        echo "CEP: ". $cep ."<br>";
                        echo "CNPJ: ". $cnpj;
                    ?>
                </li>
                <?php 
                $contador++;
                endforeach; 
                ?>                   
            </ul>
        </div>
    </div>
</div>